package com.shangxian.giveithome.controller;

import com.shangxian.giveithome.annoaction.CheckLoginStatus;
import com.shangxian.giveithome.entity.report.BlackList;
import com.shangxian.giveithome.entity.report.InputBlackList.ReportList;
import com.shangxian.giveithome.result.Result;
import com.shangxian.giveithome.service.ReportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author Administrator
 * 举报模块
 */
@Api(tags = "旧版举报模块")
//@RestController
//@RequestMapping("/report")
public class ReportController {

    @Autowired
    private ReportService reportService;

    @PostMapping("/submitReport")
    @ApiOperation(value = "提交举报")
    @CheckLoginStatus
    public Result submitReport(@Valid@RequestBody ReportList reportList){
        reportService.submitReport(reportList);
        return Result.success();
    }

    @GetMapping("/findBlackListByPhone")
    @ApiOperation(value = "通过手机号查询黑名单")
    @CheckLoginStatus
    public Result findBlackListByPhone(@RequestParam("id") long id, @PageableDefault(page = 0, size = 10) Pageable pageable){
        return Result.success(reportService.findBlackListByPhone(id,pageable));
    }

    @GetMapping("/findBlackListByWechat")
    @ApiOperation(value = "通过微信号查询黑名单")
    @CheckLoginStatus
    public Result findBlackListByWechat(@RequestParam("Wechat") String Wechat, @PageableDefault(page = 0, size = 10) Pageable pageable){
        return Result.success(reportService.findBlackListByWechat(Wechat,pageable));
    }

    @GetMapping("/findBlackListDetails")
    @ApiOperation(value = "根据黑名单记录id查询详细信息")
    @CheckLoginStatus
    public Result findBlackListDetails(@ApiParam(value = "黑名单记录id")@RequestParam("id") long id){
        return Result.success(reportService.findBlackListDetails(id));
    }

    @GetMapping("/backFindBlackListUserA")
    @ApiOperation(value = "通过后台查看黑名单中待审核的用户的信息")
    public Result backFindBlackListUserA(@PageableDefault(page = 0,size = 10) Pageable pageable){
        return  Result.success(reportService.backFindBlackListUserA(pageable));
    }

    @GetMapping("/backFindBlackListUserB")
    @ApiOperation(value = "通过后台查看黑名单中审核禁用的用户的信息")
    public Result backFindBlackListUserB(@PageableDefault(page = 0,size = 10) Pageable pageable){
        return  Result.success(reportService.backFindBlackListUserB(pageable));
    }

    @GetMapping("/backFindBlackListUserC")
    @ApiOperation(value = "通过后台查看黑名单中审核正常的用户的信息")
    public Result backFindBlackListUserC(@PageableDefault(page = 0,size = 10) Pageable pageable){
        return  Result.success(reportService.backFindBlackListUserC(pageable));
    }

    @GetMapping("/backFindBlackListDetailsListA")
    @ApiOperation(value = "通过后台查看黑名单中待审核的用户的举报信息记录")
    public Result backFindBlackListDetailsListA(@ApiParam(value = "被举报用户report_id")@RequestParam("id") long id, @PageableDefault(page = 0,size = 10) Pageable pageable){
        return Result.success(reportService.backFindBlackListDetailsListA(id,pageable));
    }

    @GetMapping("/backFindBlackListDetailsListB")
    @ApiOperation(value = "通过后台查看黑名单中审核禁用的用户的举报信息记录")
    public Result backFindBlackListDetailsListB(@ApiParam(value = "被举报用户report_id")@RequestParam("id") long id, @PageableDefault(page = 0,size = 10) Pageable pageable){
        return Result.success(reportService.backFindBlackListDetailsListB(id,pageable));
    }

    @GetMapping("/backFindBlackListDetailsListC")
    @ApiOperation(value = "通过后台查看黑名单中审核正常的用户的举报信息记录")
    public Result backFindBlackListDetailsListC(@ApiParam(value = "被举报用户report_id")@RequestParam("id") long id, @PageableDefault(page = 0,size = 10) Pageable pageable){
        return Result.success(reportService.backFindBlackListDetailsListC(id,pageable));
    }

    @GetMapping("/backFindBlackListUserDetails")
    @ApiOperation(value = "通过后台查询黑名单中举报记录详情信息")
    public Result backFindBlackListUserDetails(@ApiParam(value = "黑名单记录id") @RequestParam("id") long id){
        return Result.success(reportService.backFindBlackListUserDetails(id));
    }

    @PostMapping("/backDisableUser")
    @ApiOperation("通过后台禁用用户")
    public Result backDisableUser(@ApiParam(value = "被举报用户对象")@RequestBody BlackList blackList){
        reportService.backDisableUser(blackList);
        return Result.success();
    }

    @PostMapping("/backNormalUser")
    @ApiOperation(value = "通过后台审核正常用户")
    public Result backNormalUser(@ApiParam(value = "被举报用户对象")@RequestBody BlackList blackList){
        reportService.backNormalUser(blackList);
        return Result.success();
    }






}
